home *** CD-ROM | disk | FTP | other *** search
/ Aminet 48 / Aminet 48 (2002)(GTI - Schatztruhe)[!][Apr 2002].iso / Aminet / text / edit / vim60rt.lha / Vim / vim60 / syntax / tads.vim < prev    next >
Encoding:
Text File  |  2001-05-07  |  7.1 KB  |  185 lines

  1. " Vim syntax file
  2. " Language:    TADS
  3. " Maintainer:    Amir Karger <karger@post.harvard.edu>
  4. " $Date: 2001/05/06 18:19:52 $
  5. " $Revision: 1.6 $
  6. " Stolen from: Bram Moolenaar's C language file
  7. " Newest version at: http://www.hec.utah.edu/~karger/vim/syntax/tads.vim
  8. " History info at the bottom of the file
  9.  
  10. " TODO lots more keywords
  11. " global, self, etc. are special *objects*, not functions. They should
  12. " probably be a different color than the special functions
  13. " Actually, should cvtstr etc. be functions?! (change tadsFunction)
  14. " Make global etc. into Identifiers, since we don't have regular variables?
  15.  
  16. " For version 5.x: Clear all syntax items
  17. " For version 6.x: Quit when a syntax file was already loaded
  18. if version < 600
  19.   syntax clear
  20. elseif exists("b:current_syntax")
  21.   finish
  22. endif
  23.  
  24. " A bunch of useful keywords
  25. syn keyword tadsStatement    goto break return continue pass
  26. syn keyword tadsLabel        case default
  27. syn keyword tadsConditional    if else switch
  28. syn keyword tadsRepeat        while for do
  29. syn keyword tadsStorageClass    local compoundWord formatstring specialWords
  30. syn keyword tadsBoolean         nil true
  31.  
  32. " TADS keywords
  33. syn keyword tadsKeyword         replace modify
  34. syn keyword tadsKeyword         global self inherited
  35. " builtin functions
  36. syn keyword tadsKeyword         cvtstr cvtnum caps lower upper substr
  37. syn keyword tadsKeyword         say length
  38. syn keyword tadsKeyword         setit setscore
  39. syn keyword tadsKeyword         datatype proptype
  40. syn keyword tadsKeyword         car cdr
  41. syn keyword tadsKeyword         defined isclass
  42. syn keyword tadsKeyword         find firstobj nextobj
  43. syn keyword tadsKeyword         getarg argcount
  44. syn keyword tadsKeyword         input yorn askfile
  45. syn keyword tadsKeyword         rand randomize
  46. syn keyword tadsKeyword         restart restore quit save undo
  47. syn keyword tadsException       abort exit exitobj
  48.  
  49. syn keyword tadsTodo contained    TODO FIXME XXX
  50.  
  51. " String and Character constants
  52. " Highlight special characters (those which have a backslash) differently
  53. syn match tadsSpecial contained    "\\."
  54. syn region tadsDoubleString        start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=tadsSpecial,tadsEmbedded
  55. syn region tadsSingleString        start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=tadsSpecial
  56. " Embedded expressions in strings
  57. syn region tadsEmbedded contained       start="<<" end=">>" contains=tadsKeyword
  58.  
  59. " TADS doesn't have \xxx, right?
  60. "syn match cSpecial contained    "\\[0-7][0-7][0-7]\=\|\\."
  61. "syn match cSpecialCharacter    "'\\[0-7][0-7]'"
  62. "syn match cSpecialCharacter    "'\\[0-7][0-7][0-7]'"
  63.  
  64. "catch errors caused by wrong parenthesis
  65. "syn region cParen        transparent start='(' end=')' contains=ALLBUT,cParenError,cIncluded,cSpecial,cTodo,cUserCont,cUserLabel
  66. "syn match cParenError        ")"
  67. "syn match cInParen contained    "[{}]"
  68. syn region tadsBrace        transparent start='{' end='}' contains=ALLBUT,tadsBraceError,tadsIncluded,tadsSpecial,tadsTodo
  69. syn match tadsBraceError        "}"
  70.  
  71. "integer number (TADS has no floating point numbers)
  72. syn case ignore
  73. syn match tadsNumber        "\<[0-9]\+\>"
  74. "hex number
  75. syn match tadsNumber        "\<0x[0-9a-f]\+\>"
  76. syn match tadsIdentifier    "\<[a-z][a-z0-9_$]*\>"
  77. syn case match
  78. " flag an octal number with wrong digits
  79. syn match tadsOctalError        "\<0[0-7]*[89]"
  80.  
  81. " Removed complicated c_comment_strings
  82. syn region tadsComment        start="/\*" end="\*/" contains=tadsTodo
  83. syn match tadsComment        "//.*" contains=tadsTodo
  84. syntax match tadsCommentError    "\*/"
  85.  
  86. syn region tadsPreCondit    start="^\s*#\s*\(if\>\|ifdef\>\|ifndef\>\|elif\>\|else\>\|endif\>\)" skip="\\$" end="$" contains=tadsComment,tadsString,tadsNumber,tadsCommentError
  87. syn region tadsIncluded contained start=+"+ skip=+\\\\\|\\"+ end=+"+
  88. syn match tadsIncluded contained "<[^>]*>"
  89. syn match tadsInclude        "^\s*#\s*include\>\s*["<]" contains=tadsIncluded
  90. syn region tadsDefine        start="^\s*#\s*\(define\>\|undef\>\)" skip="\\$" end="$" contains=ALLBUT,tadsPreCondit,tadsIncluded,tadsInclude,tadsDefine,tadsInBrace,tadsIdentifier
  91.  
  92. syn region tadsPreProc start="^\s*#\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" contains=ALLBUT,tadsPreCondit,tadsIncluded,tadsInclude,tadsDefine,tadsInParen,tadsIdentifier
  93.  
  94. " Highlight User Labels
  95. " TODO labels for gotos?
  96. "syn region    cMulti        transparent start='?' end=':' contains=ALLBUT,cIncluded,cSpecial,cTodo,cUserCont,cUserLabel,cBitField
  97. " Avoid matching foo::bar() in C++ by requiring that the next char is not ':'
  98. "syn match    cUserCont    "^\s*\I\i*\s*:$" contains=cUserLabel
  99. "syn match    cUserCont    ";\s*\I\i*\s*:$" contains=cUserLabel
  100. "syn match    cUserCont    "^\s*\I\i*\s*:[^:]" contains=cUserLabel
  101. "syn match    cUserCont    ";\s*\I\i*\s*:[^:]" contains=cUserLabel
  102.  
  103. "syn match    cUserLabel    "\I\i*" contained
  104.  
  105. " identifier: class-name [, class-name [...]] [property-list] ;
  106. " Don't highlight comment in class def
  107. syn match tadsClassDef          "\<class\>[^/]*" contains=tadsObjectDef,tadsClass
  108. syn match tadsClass contained   "\<class\>"
  109. syn match tadsObjectDef "\<[a-zA-Z][a-zA-Z0-9_$]*\s*:\s*[a-zA-Z0-9_$]\+\(\s*,\s*[a-zA-Z][a-zA-Z0-9_$]*\)*\(\s*;\)\="
  110. syn keyword tadsFunction contained function
  111. syn match tadsFunctionDef        "\<[a-zA-Z][a-zA-Z0-9_$]*\s*:\s*function[^{]*" contains=tadsFunction
  112. "syn region tadsObject            transparent start = '[a-zA-Z][\i$]\s*:\s*' end=";" contains=tadsBrace,tadsObjectDef
  113.  
  114. " How far back do we go to find matching groups
  115. if !exists("tads_minlines")
  116.   let tads_minlines = 15
  117. endif
  118. exec "syn sync ccomment tadsComment minlines=" . tads_minlines
  119. if !exists("tads_sync_dist")
  120.   let tads_sync_dist = 100
  121. endif
  122. execute "syn sync maxlines=" . tads_sync_dist
  123.  
  124. " Define the default highlighting.
  125. " For version 5.7 and earlier: only when not done already
  126. " For version 5.8 and later: only when an item doesn't have highlighting yet
  127. if version >= 508 || !exists("did_tads_syn_inits")
  128.   if version < 508
  129.     let did_tads_syn_inits = 1
  130.     command -nargs=+ HiLink hi link <args>
  131.   else
  132.     command -nargs=+ HiLink hi def link <args>
  133.   endif
  134.  
  135.   " The default methods for highlighting.  Can be overridden later
  136.   HiLink tadsFunctionDef Function
  137.   HiLink tadsFunction  Structure
  138.   HiLink tadsClass     Structure
  139.   HiLink tadsClassDef  Identifier
  140.   HiLink tadsObjectDef Identifier
  141. " no highlight for tadsEmbedded, so it prints as normal text w/in the string
  142.  
  143.   HiLink tadsOperator    Operator
  144.   HiLink tadsStructure    Structure
  145.   HiLink tadsTodo    Todo
  146.   HiLink tadsLabel    Label
  147.   HiLink tadsConditional    Conditional
  148.   HiLink tadsRepeat    Repeat
  149.   HiLink tadsException    Exception
  150.   HiLink tadsStatement    Statement
  151.   HiLink tadsStorageClass    StorageClass
  152.   HiLink tadsKeyWord   Keyword
  153.   HiLink tadsSpecial    SpecialChar
  154.   HiLink tadsNumber    Number
  155.   HiLink tadsBoolean    Boolean
  156.   HiLink tadsDoubleString    tadsString
  157.   HiLink tadsSingleString    tadsString
  158.  
  159.   HiLink tadsOctalError    tadsError
  160.   HiLink tadsCommentError    tadsError
  161.   HiLink tadsBraceError    tadsError
  162.   HiLink tadsInBrace    tadsError
  163.   HiLink tadsError    Error
  164.  
  165.   HiLink tadsInclude    Include
  166.   HiLink tadsPreProc    PreProc
  167.   HiLink tadsDefine    Macro
  168.   HiLink tadsIncluded    tadsString
  169.   HiLink tadsPreCondit    PreCondit
  170.  
  171.   HiLink tadsString    String
  172.   HiLink tadsComment    Comment
  173.  
  174.   delcommand HiLink
  175. endif
  176.  
  177.  
  178. let b:current_syntax = "tads"
  179.  
  180. " Changes:
  181. " 11/18/99 Added a bunch of TADS functions, tadsException
  182. " 10/22/99 Misspelled Moolenaar (sorry!), c_minlines to tads_minlines
  183. "
  184. " vim: ts=8
  185.